package com.link2room.rodimus.service;

import com.link2room.common.jpa.result.QueryResult;
import com.link2room.rodimus.dto.param.base.SignInBaseDto;
import com.link2room.rodimus.entity.*;

import java.util.Date;
import java.util.List;

/**
 * Created by LN on 2018/1/3
 */
public interface ISignInService {
    /**
     * 补签
     *
     * @param reissueDate
     * @param memberNo
     */
    SignInDetailEntity reissue(String lhotelGroupCode, Date reissueDate, String memberNo) throws Exception;

    /**
     * 获得当前签到活动详情
     * IsAutoExtension = T 时，为有效
     *
     * @return
     */
    SignInBaseDto getUnderwaySignBaseWithAwardInfo(String lhotelGroupCode) throws Exception;

    /**
     * 是否有当前活动
     * @param lhotelGroupCode
     * @return
     */
    boolean hasUnderwaySignBase(String lhotelGroupCode) throws Exception;

    /**
     * 获取当前活动详情 包括 奖品规则 补签规则
     *
     * @param lhotelGroupCode
     * @return
     * @throws Exception
     */
    SignInBaseDto getUnderwaySignInBaseAll(String lhotelGroupCode) throws Exception;

    /**
     * 查询所有签到活动列表
     *
     * @param lhotelGroupCode
     * @return
     */
    QueryResult<SignInBaseDto> getSignInRuleBaseAll(String lhotelGroupCode, Integer currentPage, Integer pageSize) throws Exception;

    /**
     * 查找签到
     *
     * @param lhotelGroupCode
     * @param code
     * @return
     * @throws Exception
     */
    SignInBaseDto getSignInBase(String lhotelGroupCode, String code) throws Exception;

    /**
     * 当月签到列表
     */
    QueryResult<SignInDetailEntity> signInDetail(Date month, String lhotelGroupCode, String memberNo) throws Exception;

    /***
     * 保存补签详情
     * @param reissueBase
     * @param shareDetail
     */
    void saveReissue(SignInReissueBaseEntity reissueBase, List<SignInReissueDetailShareEntity> shareDetail) throws Exception;

    /**
     * 每日奖励
     *
     * @param dayNum
     * @param couldLoopDraw
     * @return
     */
    boolean isEveryAward(int dayNum, String couldLoopDraw);

    /**
     * 是否存在
     *
     * @param lhotelGroupCode
     * @param code
     * @return
     */
    boolean isRuleBaseExit(String lhotelGroupCode, String code, String title) throws Exception;

    long countRuleBaseExit(String lhotelGroupCode, String code, String title) throws Exception;

    /**
     * 奖励base是否存在
     *
     * @param lhotelGroupCode
     * @param code
     * @return
     * @throws Exception
     */
    boolean isAwardBaseExit(String lhotelGroupCode, String code);


    /**
     * 生成活动规则代码
     *
     * @return
     */
    String generateSignInRuleBaseCode(String codeType);


    /**
     * 查询奖品类型
     *
     * @param lhotelGroupCode
     * @param type
     * @return
     */
    SignInAwardTypeEntity findAwardType(String lhotelGroupCode, String type) throws Exception;

    /**
     * 保存签到base
     */
    void saveSignInRuleBase(SignInRuleBaseEntity newSignInRule, SignInRuleBaseEntity nowSignInRule, List<SignInAwardBaseEntity> awardEntities, List<SignInAwardMappingEntity> awardMappings, List<SignInReissueRuleEntity> signInReissueRuleEntities, List<SignInReissueMappingEntity> signInReissueMappingEntities) throws Exception;

    /**
     * 签到活动是否在进行中
     *
     * @param lhotelGroupCode
     * @param signInRuleCode
     * @return
     */
    boolean signInRuleIsInUse(String lhotelGroupCode, String signInRuleCode) throws Exception;

    /**
     * 查询前一个活动
     * @return
     */
    SignInRuleBaseEntity findPreviousRuleBaseEntity(SignInRuleBaseEntity signInRuleBase) throws Exception;

    /**
     * 更新签到规则

     */
    void modifySignInRule(ModifySignInRule modifySignInRule) throws Exception;

    class ModifySignInRule {
        /**
         * * @param signInRuleBasesToModify 修改的signRule
         */
        List<SignInRuleBaseEntity> signInRuleBasesToModify;
        /**
         * newSignInAwardBases 新的奖励
         */
        List<SignInAwardBaseEntity> newSignInAwardBases;
        /**
         * newSignInAwardMappingEntities 新的奖励mapping
         */
        List<SignInAwardMappingEntity> newSignInAwardMappingEntities;
        /**
         * delSignInAwardBases 要删除奖励
         */
        List<SignInAwardBaseEntity> delSignInAwardBases;
        /**
         * delSignInAwardMappingEntities 要删除奖励mapping
         */
        List<SignInAwardMappingEntity> delSignInAwardMappingEntities;
        /**
         * newSignInReissueRuleEntities 新的补签
         */
        List<SignInReissueRuleEntity> newSignInReissueRuleEntities;
        /**
         * newSignInReissueMappingEntities 新的补签mapping
         */
        List<SignInReissueMappingEntity> newSignInReissueMappingEntities;
        /**
         * delSignInReissueRuleEntities 要删除的补签
         */
        List<SignInReissueRuleEntity> delSignInReissueRuleEntities;
        /**
         * delSignInReissueMappingEntities 要删除的补签mapping
         */
        List<SignInReissueMappingEntity> delSignInReissueMappingEntities;

        public List<SignInRuleBaseEntity> getSignInRuleBasesToModify() {
            return signInRuleBasesToModify;
        }

        public void setSignInRuleBasesToModify(List<SignInRuleBaseEntity> signInRuleBasesToModify) {
            this.signInRuleBasesToModify = signInRuleBasesToModify;
        }

        public List<SignInAwardBaseEntity> getNewSignInAwardBases() {
            return newSignInAwardBases;
        }

        public void setNewSignInAwardBases(List<SignInAwardBaseEntity> newSignInAwardBases) {
            this.newSignInAwardBases = newSignInAwardBases;
        }

        public List<SignInAwardMappingEntity> getNewSignInAwardMappingEntities() {
            return newSignInAwardMappingEntities;
        }

        public void setNewSignInAwardMappingEntities(List<SignInAwardMappingEntity> newSignInAwardMappingEntities) {
            this.newSignInAwardMappingEntities = newSignInAwardMappingEntities;
        }

        public List<SignInAwardBaseEntity> getDelSignInAwardBases() {
            return delSignInAwardBases;
        }

        public void setDelSignInAwardBases(List<SignInAwardBaseEntity> delSignInAwardBases) {
            this.delSignInAwardBases = delSignInAwardBases;
        }

        public List<SignInAwardMappingEntity> getDelSignInAwardMappingEntities() {
            return delSignInAwardMappingEntities;
        }

        public void setDelSignInAwardMappingEntities(List<SignInAwardMappingEntity> delSignInAwardMappingEntities) {
            this.delSignInAwardMappingEntities = delSignInAwardMappingEntities;
        }

        public List<SignInReissueRuleEntity> getNewSignInReissueRuleEntities() {
            return newSignInReissueRuleEntities;
        }

        public void setNewSignInReissueRuleEntities(List<SignInReissueRuleEntity> newSignInReissueRuleEntities) {
            this.newSignInReissueRuleEntities = newSignInReissueRuleEntities;
        }

        public List<SignInReissueMappingEntity> getNewSignInReissueMappingEntities() {
            return newSignInReissueMappingEntities;
        }

        public void setNewSignInReissueMappingEntities(List<SignInReissueMappingEntity> newSignInReissueMappingEntities) {
            this.newSignInReissueMappingEntities = newSignInReissueMappingEntities;
        }

        public List<SignInReissueRuleEntity> getDelSignInReissueRuleEntities() {
            return delSignInReissueRuleEntities;
        }

        public void setDelSignInReissueRuleEntities(List<SignInReissueRuleEntity> delSignInReissueRuleEntities) {
            this.delSignInReissueRuleEntities = delSignInReissueRuleEntities;
        }

        public List<SignInReissueMappingEntity> getDelSignInReissueMappingEntities() {
            return delSignInReissueMappingEntities;
        }

        public void setDelSignInReissueMappingEntities(List<SignInReissueMappingEntity> delSignInReissueMappingEntities) {
            this.delSignInReissueMappingEntities = delSignInReissueMappingEntities;
        }
    }
}
